<?php

session_start();


$last_page = $_SESSION["last_page"];
function show_content () {
    //global $check;
    //global $folders;
    global $file;
    //$url = "modules/articles/content/";
    //for ($f=1;$f<count($folders)-1;$f++) {
    //    $url = $url . $folders[$f] . "/";
    //}
    //$url = $url . $file;
    global $article;
		
		if (isset($_SESSION["username"]) && file_exists($article . ".edit")) {
			 include $article. ".edit";
			 $_SESSION["edit_on"] = true;
	  } else if (file_exists($article)) {
			include $article;
			if(isset($_SESSION["edit_on"])) unset($_SESSION["edit_on"]);
		}
    else {
		     echo $article;
				 echo "<p>$file does not exist</p>";
				 if(isset($_SESSION["edit_on"])) unset($_SESSION["edit_on"]);
		}
}

function isSmartPhone() {
      if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Android') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Blackberry') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') || 
         strstr($_SERVER['HTTP_USER_AGENT'], 'OperaMobi') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'IEMobile') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Jasmine') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Fennec') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Blazer') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Minimo') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'MOT-') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Nokia') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'SAMSUNG') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'Polaris') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'LG-') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'SonyEricsson') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'hiptop') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'avantgo') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'plucker') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'SIE-') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'xiino') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'elaine') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'AUDIOVOX') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'mobile') ||
         strstr($_SERVER['HTTP_USER_AGENT'], 'webOS')) return true;
	else return false;
}

function include_module ($module_name, $no_mobile = false) {
     global $config;
		 
		 $not_smart_phone = false;
		 if ($no_mobile) $not_smart_phone = isSmartPhone();
		 
		 
     if (! $not_smart_phone ) {
     		if (array_key_exists($module_name,$config) && $config[$module_name] && is_dir("modules/{$module_name}")) {
		    	 echo "\n<!-- include dsquared module {$module_name} -->\n";
		 			 include "modules/{$module_name}/index.php"; 
					 return true;
		 		} else {
		   		echo "\n<!-- dsquared module {$module_name} not shown -->\n";
		 	 		return false;
		 		} 
		} else {
			echo "\n<!-- dsquared module {$module_name} enabled in mobile -->\n";
			return true;
		}
}

function essential_module ($module_name, $no_mobile = false) {
  global $config;
  if (! include_module($module_name, $no_mobile)) {
	 echo "Unable to continue without the {$module_name} module";
	 exit;
  }
}

?>